#ifndef _ASYNDBOPT_H
#define _ASYNDBOPT_H
#include <string>
using std::string;
#include "WorkQueue/WorkQueue.h"

#include "mysql++.h"

class DBWorkQueue : public WorkQueue
{
public:
	virtual void WorkRoutine();
};
class AsynDB_CallBack
{
public:
	AsynDB_CallBack();
	virtual ~AsynDB_CallBack();

	virtual void process() = 0;
	void setResult(int index,const mysqlpp::StoreQueryResult& _result);
protected:
	enum
	{
		Result_Count = 4,
	};
	mysqlpp::StoreQueryResult m_result[Result_Count];

};

class DBQueryItem : public WorkItem
{
public:
	DBQueryItem(mysqlpp::TCPConnection* _pCon,mysqlpp::Query& _query,AsynDB_CallBack* pCallBack);
	virtual void Run();
protected:
	AsynDB_CallBack*        m_pCallBack;
	mysqlpp::Query          m_query;
	mysqlpp::TCPConnection* m_pCon;
};

class DBTemplateQuery : public DBQueryItem
{
public:
	DBTemplateQuery(mysqlpp::TCPConnection* _pCon,mysqlpp::Query& _query,AsynDB_CallBack* pCallBack,const mysqlpp::SQLQueryParms& str);
	virtual void Run();
private:
	mysqlpp::SQLQueryParms m_queryParms;
};




#endif